1 using UnityEngine;
2 using
System.Collections;
3
4 public
class UpgradeInfo{
5
6     
private int[,] upgrades;
7     
private int[,] costCoinBases;
8
9     
private int[] speeds;
10     
private int[] jumps;
11
12     
public UpgradeInfo()
13     {
14         upgrades =
new int[2,10];
15         costCoinBases =
new int[2, 10];
16         
for(int i = 0 ; i < 2 ; i ++)
17             
for (int j = 0; j < 10; j++)
18             {
19                 upgrades[i, j] = Data.getData(Data.KEY_UPGRADE + i +
"" + j);
20                 costCoinBases[i, j] =
500;
21             }
22
23         speeds =
new int[] { 150, 160, 170, 180, 190, 200, 210, 220, 230, 240 };//so voi 3
24         jumps =
new int[] { 250, 260, 270, 280, 290, 300, 310, 320, 330, 340 };//so voi 5
25     }
26
27     
public void upgrade(int animalIndex, int item)
28     {
29         
if (upgrades[item, animalIndex] < 5)
30         {
31             upgrades[item, animalIndex]++;
32             Data.saveData(Data.KEY_UPGRADE + item +
"" + animalIndex, upgrades[item,animalIndex]);
33         }
34     }
35
36     
//get speed or jump of current or next
37     
public int getItem(int animalIndex, int item, bool next)
38     {
39         
switch (item)
40         {
41             
case 0:
42                 
return speeds[animalIndex] + (upgrades[item, animalIndex] - (next ? 0 : 1)) * 10;
43             
case 1:
44                 
return jumps[animalIndex] + (upgrades[item, animalIndex] - (next ? 0 : 1)) * 10;
45         }
46         
return -1;
47     }
48
49     
public int getLevel(int animalIndex, int item)
50     {
51         
return upgrades[item, animalIndex];
52     }
53
54     
public int getCostItem(int animalIndex, int item)
55     {
56         
return costCoinBases[item, animalIndex] * upgrades[item, animalIndex];
57     }
58
59     
public int getSpeed(int animalIndex)
60     {
61         
return speeds[animalIndex];
62     }
63
64     
public int getJump(int animalIndex)
65     {
66         
return jumps[animalIndex];
67     }
68 }


speeds = new int[] { 150, 160, 170, 180, 190, 200, 210, 220, 230, 240 };so voi 3

jumps = new int[] { 250, 260, 270, 280, 290, 300, 310, 320, 330, 340 };so voi 5

get speed or jump of current or next




Trò chơi đua xe động vật trong UNITY Engine 114.943 lượt xem

Gõ tìm kiếm nhanh...